//
//  SLBaseTableViewController.swift
//  Sina15
//
//  Created by 盼 on 16/4/8.
//  Copyright © 2016年 pan. All rights reserved.
//

import UIKit

class SLBaseTableViewController: UITableViewController,SLVisitorViewDelegate {

    //设置属性标记用户是否已经登录
    var userLogin:Bool = SLUserViewModel.sharedModel.userLogin
    
    var visitorView:SLVisitorView?
    
    //重写loadView方法
    override func loadView() {
        
        userLogin ? super.loadView() : prepareForVisitorLogin()
    }
    
    
    //加载引导游客登录页面
    private func prepareForVisitorLogin(){
        
        visitorView = SLVisitorView()
        
        //设置代理
        visitorView?.delegate = self
        
        view = visitorView
        
        //设置导航条
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
    }
    
    
    //MARK:实现代理方法
    //用户注册方法
    func userWillRegister(){
        
        print("注册")
    }
    
    //用户登录方法
    func userWillLogin(){
        
         print("登录")
        
        let OAuthVC = SLOAuthController()
        
        let navVC = UINavigationController(rootViewController: OAuthVC)
        
        presentViewController(navVC, animated: true, completion: nil)
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
}
